package com.nuo.admin.base.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nuo.admin.base.entity.SysOauthClient;
import com.nuo.admin.base.service.ISysOauthClientService;
import com.nuo.admin.base.mapper.SysOauthClientMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
* @author LGC
* @description 针对表【sys_oauth_client(客户端表)】的数据库操作Service实现
* @createDate 2022-02-09 11:35:10
*/
@Service
@RequiredArgsConstructor
public class ISysOauthClientServiceImpl extends ServiceImpl<SysOauthClientMapper, SysOauthClient>
    implements ISysOauthClientService {

    private final StringRedisTemplate stringRedisTemplate;

    /**
     * 清理客户端缓存
     */
    @Override
    public void cleanCache() {
        Set<String> keys = stringRedisTemplate.keys("auth:oauth-client:*");
        if (CollectionUtil.isNotEmpty(keys)) {
            stringRedisTemplate.delete(keys);
        }
    }
}




